﻿using Microsoft.Xna.Framework.Graphics;

namespace XNA_Game_Engine.Characters
{
    public abstract class Character
    {
        public abstract void Update(float gameTime);
        public abstract void Render(SpriteBatch renderTarget);

        protected double x;
        protected double y;
        protected double OldX, OldY;
        protected int Width, Height;
        protected float Speed;
        protected float Angle;
        //protected AnimatedSprite Sprite;
        //protected bool jumping;

        public bool IsColliding(Character c)
        {
            if (this != c)
            {
                if (x + Width > c.x && x < c.x + c.Width)
                {
                    if (y + Height > c.y && y < c.y + c.Height)
                    {
                        return true;
                    }
                }               
            }
            return false;
        }

    
        public void IsOutOfBounds(int width, int height)
        {
            if (this.x + this.Width >= width || this.x <= 0)
            {
                x = OldX;
                y = OldY;
                Speed *= -1;
                return;
            }
            if (this.y + this.Height >= height || this.y <= 0)
            {
                x = OldX;
                y = OldY;
                Speed *= -1;
                return;
            }
        }


        public void StepBack()
        {
            x = OldX;
            y = OldY;
            Speed *= -1;
            Speed *= -1;
        }

        public double X
        {
            get { return x; }
            set { x = value; }
        }

        public double Y
        {
            get { return y; }
            set { y = value; }
        }

        //public bool isJumping()
        //{
        //    return jumping;
        //}

    } // Character

}
